﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace SqlServices
{
    //采用INternal作为限制
    internal class GetSqlConnection
    {
        private string connStr = string.Empty;
        /// <summary>
        /// 创建返回SqlConnection的实例
        /// </summary>
        public GetSqlConnection()
        {
            connStr = GetConnStr.GetConn();
        }
        /// <summary>
        /// 传入一个连接字符串 返回SqlConnection
        /// </summary>
        /// <param name="strConn"></param>
        public GetSqlConnection(string strConn)
        {
            connStr = strConn;
        }
        /// <summary>
        /// 返回SqlConnection  在这里我想说一下，有没有必要把sqlconnection做成唯一的单例模式呢？也许是太久没有和数据库打交道，很久也没想出来
        /// </summary>
        /// <returns></returns>
        public SqlConnection GetConnection()
        {
            SqlConnection conn = new SqlConnection(connStr);
            return conn;
        }
    }
}
